<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">
<body>
	<ui:composition template="/template.xhtml">
		<ui:define name="title">
                User Session (Stateful EJB)
            </ui:define>
		<ui:define name="body">
			<div class="row">
				<div class="span6">
					<h:form id="addWindowForm" class="form-horizontal">
						<h2>New window:</h2>
						<div class="control-group">
							<h:outputLabel value="Name: " class="control-label" />
							<div class="controls">
								<h:inputText value="${backingBean.newWindowName}" />
							</div>
						</div>
						
						<div class="control-group">					
							<h:outputLabel value="Possition X: " class="control-label" />
							<div class="controls">
								<h:inputText value="${backingBean.newWindowXPosition}" size="2" />
							</div>
						</div>
						<div class="control-group">		
							<h:outputLabel value="Possition Y: " class="control-label" />
							<div class="controls">
								<h:inputText value="${backingBean.newWindowYPosition}" size="2"/>
							</div>
						</div>
						
						<div class="control-group">
							<div class="controls">
								<h:commandButton value="Create" action="${backingBean.addWindow()}" class="btn btn-primary" />
							</div>
						</div>
					</h:form>
				</div>
				<div class="span6">
					<h:form id="activeWindowsForm">
						<h2>User's opened windows:</h2>
							<h:dataTable var="current" value="#{backingBean.allWindows}" class="table table-striped" >
								<h:column>
									<f:facet name="header" >
										<h:outputText value="Windows Name"/>
									</f:facet> 
									<h:outputText value="#{current.name}" />
								</h:column>
								<h:column>
									<f:facet name="header" >
										<h:outputText value="X Position"/>
									</f:facet>
									<h:outputText value="#{current.position.x}" />
								</h:column>
								<h:column>
									<f:facet name="header" >
										<h:outputText value="Y Position"/>
									</f:facet>
									<h:outputText value="#{current.position.y}" />
								</h:column>
								<h:column>
									<f:facet name="header" >
										<h:commandLink value="Close all" action="${backingBean.clossAll()}" />
									</f:facet>
									<h:commandLink value="Close" action="${backingBean.closeWindow(current.name)}" />
								</h:column>
							</h:dataTable>
					</h:form>
				</div>
			</div>
		</ui:define>
	</ui:composition>
</body>
</html>
